package cn.doitedu.utils;

import cn.doitedu.pojo.EventCondition;
import cn.doitedu.pojo.LogBean;

import java.util.Map;

/**
 * @create: 2021-11-13 22:45
 * @author: 静如海的男人
 * @program: eagle-text
 **/

public class EventComparator {
    public static boolean isMatchTriggerEvent(LogBean bean, EventCondition tet) {

        if (tet!=null) {
            //判断行为是否匹配
            if (tet.getEventId().equals(bean.getEventId())) {
                //prs定义的规则
                Map<String, String> prs = tet.getProperties();
                Map<String, String> beanprs = bean.getProperties();
                for (String key : prs.keySet()) {
                    //判断行为属性
                    if (!prs.get(key).equals(beanprs.get(key))) {
                        return false;
                    }
                }
            }else {
                return false;
            }
        }

        return true;
    }

}
